﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace InstallManager.Msi
{
    internal static class MsiDbInterop
    {
        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        public static extern uint MsiCloseHandle(IntPtr handle);

        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        public static extern uint MsiDatabaseOpenView(IntPtr database, string query, out IntPtr view);

        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        public static extern uint MsiOpenDatabase(string databasePath, int persist, out IntPtr database);

        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        public static extern int MsiRecordGetInteger(IntPtr record, uint field);

        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        public static extern uint MsiRecordGetString(IntPtr record, uint field, StringBuilder value, ref int bufferSize);

        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        public static extern uint MsiViewExecute(IntPtr view, IntPtr parameters);

        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        public static extern uint MsiViewFetch(IntPtr view, out IntPtr record);
    }
}
